package com.itfreer.data.syn.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;

import com.itfreer.form.api.entity.EntityBase;
import com.itfreer.form.api.reflect.DictionaryField;

/**
 * 数据同步服务
 */
@Entity(name = "data_syn")
public class DataSynEntity extends EntityBase implements Serializable {

	private static final long serialVersionUID = -2739195535161688054L;

	/**
	 * 数据ID
	 */
	@Id
	@Column(name = "id", length = 50, nullable = false)
	private String id;

	/**
	 * 数据表
	 */
	@Column(name = "s_table", length = 50, nullable = true)
	private String table;

	/**
	 * 数据json格式
	 */
	@Column(name = "s_data", columnDefinition = "text", nullable = true)
	private String data;

	/**
	 * 操作类型，add, update, delete
	 */
	@Column(name = "s_type", length = 20, nullable = true)
	private String type;

	/**
	 * 记录时间
	 */
	@Column(name = "d_adddate", length = 50, nullable = true)
	private Date addDate;

	/**
	 * 同步失败的类型ID值
	 */
	@Column(name = "s_fails", length = 50, nullable = true)
	@DictionaryField(dictionaryName = "datasynconfig", toFieldName = "failsName")
	private String fails;

	@Transient
	private String failsName;

	/**
	 * 是否全部同步成功
	 */
	@Column(name = "b_all", nullable = true)
	private Boolean all;

	/**
	 * 失败次数
	 */
	@Column(name = "i_failtimes", nullable = true)
	private Integer failTimes;

	/**
	 * 创建人
	 */
	@Column(name = "s_adduserid", length = 50, nullable = true)
	private String addUserID;

	/**
	 * 创建人
	 */
	@Column(name = "s_addusername", length = 50, nullable = true)
	private String addUserName;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getAddDate() {
		return addDate;
	}

	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	@Transient
	public String[] getFailsName() {
		return super.getStringArray(failsName);
	}

	public void setFailsName(String[] failsName) {
		this.failsName = super.getArrayString(failsName);
	}

	public String[] getFails() {
		return super.getStringArray(fails);
	}

	public void setFails(String[] fails) {
		this.fails = super.getArrayString(fails);
	}

	public Boolean getAll() {
		return all;
	}

	public void setAll(Boolean all) {
		this.all = all;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Integer getFailTimes() {
		return failTimes;
	}

	public void setFailTimes(Integer failTimes) {
		this.failTimes = failTimes;
	}

	public String getAddUserID() {
		return addUserID;
	}

	public void setAddUserID(String addUserID) {
		this.addUserID = addUserID;
	}

	public String getAddUserName() {
		return addUserName;
	}

	public void setAddUserName(String addUserName) {
		this.addUserName = addUserName;
	}

	/**
	 * 设置创建人值
	 */
	public void setCreateUserID(String userID) {
		this.addUserID = userID;
	}

	/**
	 * 设置创建人值
	 */
	public void setCreateUserName(String userName) {
		this.addUserName = userName;
	}
}
